package org.manager.authorize;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

public class SystemRole implements Serializable {
	
	private static final long serialVersionUID = 3654443385411477517L;
	
	private String id;
	private String name;
	private String status;
	private String remark;
	private CreatedInformation createInfo;
	
	private Set<Function> functionSet = new HashSet<Function>();
	
	private boolean checked = false;
	
	public SystemRole() {
	}
	
	@Override
	public int hashCode() {
		int result = 17;
		result = 31*result+id.hashCode();
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(!(obj instanceof SystemRole)){
			return false;
		}
		if(((SystemRole)obj).getId().equals(id)){
			return true;
		}
		return false;
	}
	
	/**
	 * 得打该角色拥有的系统功能.
	 * @param fun 系统功能集合.
	 * @return 本角色拥有的功能.
	 */
	public Function containsFunction(Set<Function> funSet){
		for(Function f : funSet){
			if(this.functionSet.contains(f)){
				return f;
			}
		}
		return new Function();
	}
	
	public void addFunction(Function fun){
		this.functionSet.add(fun);
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public CreatedInformation getCreateInfo() {
		return createInfo;
	}
	public void setCreateInfo(CreatedInformation createInfo) {
		this.createInfo = createInfo;
	}
	public void setChecked(boolean checked) {
		this.checked = checked;
	}
	
	public boolean isChecked() {
		return checked;
	}

	public void setFunctionSet(Set<Function> functionSet) {
		this.functionSet = functionSet;
	}
	
	public Set<Function> getFunctionSet() {
		return functionSet;
	}
	
}
